﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public class STUController : Controller
    {
        Model1 model = new Model1();
        // GET: STU
        public ActionResult Index()
        {
            var list = model.StuInfo.ToList();
            return View(list);
        }
        //详情
        public ActionResult Xiangq(string id)
        {
            
            StuInfo stu = model.StuInfo.FirstOrDefault(p =>p.StuNo == id);
            return View(stu);
        }
        //删除
        [HttpPost]
        public ActionResult Delete(string id)
        {
            StuInfo stu = model.StuInfo.FirstOrDefault(p=>p.StuNo==id);
            if (stu!=null)
            {
                model.StuInfo.Remove(stu);
                var result = model.SaveChanges() > 0;
                return Json(result);
            }
            return Json( false);
        }
        }
}